#include <stdio.h>
int judge[5][5] = {
  {0, -1, 1, 1, -1},
  {1, 0, -1, 1, -1},
  {-1, 1, 0, -1, 1},
  {-1, -1, 1, 0, 1},
  {1, 1, -1, -1, 0}
};
#define maxn 205
int n, na, nb;
int a[maxn], b[maxn];
int score[2];
int main() {
  scanf("%d%d%d", &n, &na, &nb);
  for(int i=0; i<na; ++i) scanf("%d", a+i);
  for(int i=0; i<nb; ++i) scanf("%d", b+i);
  int ia=0, ib=0;
  for(int k=0; k<n; ++k) {
    int res = judge[a[ia]][b[ib]];
    if(res > 0) score[0]++;
    else if(res < 0) score[1]++;
    ia = (ia+1)%na;
    ib = (ib+1)%nb;
  }
  printf("%d %d\n", score[0], score[1]);
}

